import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import NotFound from '@/components/home/notFound/index';
import Empty from '@/components/home/notFound/empty';
export type RouterType = RouteRecordRaw & { chname?: string; children?: any };

export const dataManage = [
  {
    chname: '数据管理',
    name: 'dataManageIndex',
    path: `/manage/dataManageIndex`,
    component: Empty
  },
  {
    chname: '权限管理',
    name: 'authority',
    path: `/manage/authority`,
    component: Empty
  }
];

const homeRouter = [
  {
    name: 'home',
    path: '/',
    component: () => import('../pages/menu/crmMenu'),
    children: [
      {
        name: 'introduce',
        chname: '介绍',
        path: '/',
        component: NotFound
      }
    ].concat(dataManage)
  }
];

export const routes: RouteRecordRaw[] = (homeRouter as RouteRecordRaw[]).concat([
  {
    name: 'notFound',
    path: '/:pathMatch(.*)*',
    component: NotFound
  }
]);

export const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHashHistory(import.meta.env.BASE_URL), // es2019编译目标下import.env不支持
  routes
});

export default router;
